package com.manage.common.enums;

/**
 * @Create by ldr.
 * @create 2018-09-06 14:34
 * @Description：返回信息枚举类
 */
public enum ResultEnum {
    SUCCESS(1,"请求成功"),
    ERROR(-1,"请求异常"),
    FAILURE(-2,"请求失败");

    private int state;

    private String stateInfo;

    ResultEnum(int state, String stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    public int getState() {
        return state;
    }

    public String getStateInfo() {
        return stateInfo;
    }

    public static ResultEnum stateOf(int index){
        for (ResultEnum state : values()){
            if (state.getState() == index ){
                return state;
            }
        }
        return null;
    }
}
